<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TestBat.Frontend.Controllers.ViewData.Test.Tasks.MultipleResponseTaskViewData>" %>

<script type="text/javascript">

    $(function() {
    $("#MultipleResponseSolution\\$<%= Model.TestTaskID %>").change(function() {
    
            // JQuery 1.4 breaks asp.net mvc's actions so we set the ajax behavior back to the old way
            jQuery.ajaxSettings.traditional = true;
      
            $.ajax( {
                url: "<%=Url.Content("~/Test/SaveMultipleResponseSolution") %>",
                data: { testTaskID: "<%=Model.TestTaskID %>", choiceIDs: $.map($('#MultipleResponseSolution\\$<%= Model.TestTaskID %>:checked'), function(e) { return $(e).val(); }) }
            });
        });
    });
</script>

<p class="question"><%= Model.Task.Question %></p>
<p class="answer">

<% foreach (TestBat.IModels.Domain.ITestChoice choice in Model.Task.Choices)
   { %>
    <span style="display:block" class="choice">
        <%= Html.CheckBox("MultipleResponseSolution$" + Model.TestTaskID.ToString(), (Model.Solution != null && Model.Solution.Picks.Contains(choice)) ? true : false, new { value = choice.ID })%>
        <%= choice.Text %>
    </span>
<% } %>

</p>
